﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Templates/Template.Master"
     Inherits="System.Web.Mvc.ViewPage<TaxiCaosWeb.Models.Cliente>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="title" runat="server">
	Registrar Cliente
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="menuContent" runat="server">
<%
    string[] menuArray = { "0", "0", "0", "0", "0", "1", "0", "0" };
    Session["menuArray"] = menuArray;
%>

</asp:Content>


<asp:Content ID="Content4" ContentPlaceHolderID="body" runat="server">

    <script type="text/javascript">


        $(document).ready(function () {

            $(".datepicker").datepicker();
            // validar formulario
            $("#clienteForm").validate({
                submitHandler: function (form) {
                    submitForm("");
                },
                rules: {
                    NumeroDocumento: "required",
                    Email: {
                        required: true,
                        email: true
                    },
                    Direccion: "required",
                    Telefono: "required",
                    FecNacimiento: "required",
                    ULogin: "required",
                    Password: "required"

                }
            });

        });

        function submitForm() {

            var $form = $("#clienteForm");

            $.ajax({
                type: "POST",
                url: $form.attr('action'),
                data: $form.serialize(),
                error: function (xhr, status, error) {
                    $.msgBox({
                        content: error,
                        type: "error"
                    });
                },
                success: function (data) {
                    $("#loading-div-background").hide();
                    if (data.tipoMensaje == 'INFO') {
                        $.msgBox({
                            content: data.mensaje,
                            type: "info",
                            afterClose: function () {
                                window.location = data.redirectTo;
                            }
                        });
                    } else if (data.tipoMensaje == 'WARN') {
                        $.msgBox({
                            content: data.mensaje,
                            type: "alert"
                        });
                    }

                },
                beforeSend: function (data) {
                    $("#loading-div-background").show();
                }
            });

            return false;
        }

    </script>

    <div class="nosotros">
        <h2> Registro de Clientes </h2>
        <br />
        <div style="margin-top: 5px; height: 285px; overflow-y: scroll;">
    <% using (Html.BeginForm("CrearCliente", "Cliente", FormMethod.Post, new { id = "clienteForm", @class = "cmxform" })){%>
        <br />
        <fieldset>
            <legend><b>Datos Usuario</b></legend>
            <table>
                <tr>
                    <td>Usuario(*)</td>
                    <td><%: Html.TextBoxFor(model => model.ULogin)%></td>
                    <td></td>
                    <td>Password(*)</td>
                    <td><%: Html.TextBoxFor(model => model.Password)%></td>
                </tr>
            </table>
        </fieldset>
        <fieldset>
            <legend><b> Datos Cliente</b></legend>
            <table>
                <tr>
                    <td>Tipo Cliente</td>
                      <td><%= Html.DropDownList("TipoCliente", (IEnumerable<SelectListItem>)ViewData["TiposClientes"])%></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>Nombres</td>
                    <td><%: Html.TextBoxFor(model => model.Nombres)%></td>
                    <td>Apellidos</td>
                    <td><%: Html.TextBoxFor(model => model.Apellidos)%></td>
                </tr>
                <tr>
                    <td>Razon Social</td>
                    <td><%: Html.TextBoxFor(model => model.RazonSocial)%></td>
                    <td></td>
                    <td></td>
                </tr>
                 <tr>
                    <td>Tipo Documento</td>
                    <td><%= Html.DropDownList("TipoDocumento", (IEnumerable<SelectListItem>)ViewData["TiposDocumentos"])%></td>
                    <td>Nº Documento (*)</td>
                    <td><%: Html.TextBoxFor(model => model.NumeroDocumento)%></td>
                </tr>
                <tr>
                    <td>Email (*)</td>
                    <td><%: Html.TextBoxFor(model => model.Email)%></td>
                    <td>Dirección(*)</td>
                    <td><%: Html.TextBoxFor(model => model.Direccion)%></td>
                </tr>
                <tr>
                    <td>Telefono(*)</td>
                    <td><%: Html.TextBoxFor(model => model.Telefono) %></td>
                    <td>Fecha Nacimiento(*)</td>
                    <td> <%: Html.TextBox("FecNacimiento", null, new { @class = "datepicker", @style = "width:100px;" })%></td>
                </tr>
               
            </table>
        </fieldset>
        <br />

           <input id="btnSubmit" type="submit" value="Guardar Datos" style="background-color: steelblue;
                color: white; font-weight: bold; margin-top: 5px;" />
     
       <% } %>     
       </div>
   </div>
</asp:Content>


